# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def create_links
    links = 
      [ 
          Link.new( :projects, 'projects', 
              [
                Link.new( :tasks, 'tasks' ) , 
                Link.new( :bugs, 'bugs' ) , 
                Link.new( :documents, 'documents') ,
                Link.new( :builds, 'builds' )
              ] 
          ),
          Link.new( :reporting, 'reporting' ),
          Link.new( :settings, 'settings' )
      ]
  end
  class Link
    attr_accessor :title, :controller_name, :action_name, :params
    attr_reader :childs
    def initialize(title, controller_name, childs = [], action_name = 'index', params = {} )
      @title = title
      @controller_name = controller_name
      @action_name = action_name
      @params = params
      @childs = childs
    end
    def generate_for_link_to
      return ({:controller => @controller_name, :action => @action_name}).update( @params )
    end
  end
  def generate_link_code
    res = "<ul>"
    res += "</ul>"
  end
end
